 import { browserHistory } from 'react-router' ;

 export function  requireAuth(nextState, replace) {
    if (!loggedIn()) {
      replace({
        pathname: '/backend/login',
        state: { nextPathname: nextState.location.pathname }
      })
    }
  }

export function getToken() {
    return localStorage.jwtToken
  }

 export function  loggedIn() {
    return !!localStorage.jwtToken
}

export function logout() {
    localStorage.removeItem("jwtToken");
    browserHistory.push('/backend/login') ;
}

export function getCurrentUser(){
  return localStorage.CurrentUser ; 
}